using System.Collections;
using System.Collections.Generic;
using Unity.Mathematics;
using UnityEngine;
/// <summary>
/// 平面几何库
/// </summary>
public static class Geo2DMath 
{
    public static Vector3 CenterPoint2D(List<Vector3> Points)
    {
        int total = Points.Count;
        float lat = 0, lon = 0;

        foreach (Vector3 p in Points)
        {
            lat += p.x;// * Mathf.PI / 180;
            lon += p.z;// * Mathf.PI / 180;        
        }

        lat /= total;
        lon /= total;

        Vector3 centerPoint = new Vector3(lat, Points[0].y, lon);
        //Debug.Log("Center " + centerPoint);
        return centerPoint;
    }
    /// <summary>
    /// 棋盘距离
    /// </summary>
    public static float DistanceChebyshev(Vector2 a,Vector2 b)
    {
        return math.max(math.abs(b.x - a.x), math.abs(b.y - a.y));
    }
    /// <summary>
    /// 出租车距离
    /// </summary>
    /// <param name="a"></param>
    /// <param name="b"></param>
    /// <returns></returns>
    public static float DistanceManhattan(Vector2 a,Vector2 b)
    {
        return math.abs(b.x - a.x) +  math.abs(b.y - a.y);
    }
}
